package com.scpii.universal.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.scpii.universal.hibernate.dao.BaseDao;
import com.scpii.universal.hibernate.entity.AttributeTab;
import com.scpii.universal.hibernate.intface.BaseInterface;
import com.scpii.universal.util.SpringBeanFactory;

public class AttributeTabService implements BaseInterface<AttributeTab> {
	private static final Logger log = LoggerFactory
			.getLogger(AttributeTabService.class);
//	private BaseDao<AttributeTab> attributeTabDao = SpringBeanFactory.attributeTabDao;
	private BaseDao<AttributeTab> attributeTabDao;

	public AttributeTab get(Integer id) throws Exception {
		return attributeTabDao.get(id);
	}

	public List<AttributeTab> getAll() throws Exception {
		return attributeTabDao.getAll();
	}

	public AttributeTab get(String propertyName, Object value) throws Exception {
		return null;
	}

	public List<AttributeTab> getList(String propertyName, Object value)
			throws Exception {
		return null;
	}

	public Long getTotalCount() throws Exception {
		return null;
	}

	public void save(AttributeTab obj) throws Exception {

	}

	public void update(AttributeTab obj) throws Exception {

	}

	public void delete(AttributeTab obj) throws Exception {

	}

	public void delete(Integer id) throws Exception {

	}

	public List<AttributeTab> hqlGetList(String hql, Map<String, Object> argsMap)
			throws Exception {
		return attributeTabDao.hqlGetList(hql, argsMap);
	}

	public void hqlUpdate(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		attributeTabDao.hqlUpdate(namedHqlQuery, argsMap);
	}

	public Long hqlGetNums(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		return attributeTabDao.hqlGetNums(namedHqlQuery, argsMap);
	}

	public List<AttributeTab> sqlGetList(String sqls,
			Map<String, Object> argsMap) throws Exception {
		return attributeTabDao.sqlGetList(sqls, argsMap);
	}

	public void sqlUpdate(String sqls, Map<String, Object> argsMap)
			throws Exception {
		attributeTabDao.sqlUpdate(sqls, argsMap);
	}

	public Long sqlGetNum(String sqls, Map<String, Object> argsMap)
			throws Exception {
		return attributeTabDao.sqlGetNum(sqls, argsMap);
	}
	
	/**
	 * 根据分类ID，获得分类下的属性列表
	 * @param catelogId
	 * @return
	 * @throws Exception
	 * @author 甘建新
	 * 2012-7-17上午02:28:57
	 */
	public List<AttributeTab> getAttributeListByCatelogId(int catelogId)throws Exception{
		if (catelogId>0) {
			List<AttributeTab> attrList = new ArrayList<AttributeTab>();
			Map<String, Object> argsMap = new HashMap<String, Object>();
			argsMap.put("catelogId", catelogId);
			attrList = this.hqlGetList("GET_ATTRIBTE_CATELOGID", argsMap);
			return attrList;
		}
		return null;
	}
	
	/**
	 * 根据属性类型查询属性
	 * @author Taylor
	 * 2012-9-16 上午01:15:49
	 * @param catelogId
	 * @param type
	 * @return
	 * @throws Exception
	 * AttributeTab
	 */
	public AttributeTab getAttributeByType(int catelogId,int type) throws Exception {
		List<AttributeTab> attrList = new ArrayList<AttributeTab>();
		Map<String, Object> argsMap = new HashMap<String, Object>();
		argsMap.put("catelogId", catelogId);
		argsMap.put("intType", type);
		attrList = this.hqlGetList("GET_ATTRIBTE_BY_TYPE", argsMap);
		if (attrList.size() > 0 ) {
			return attrList.get(0);
		}
		return null;
	}
	//Setter

	public void setAttributeTabDao(BaseDao<AttributeTab> attributeTabDao) {
		this.attributeTabDao = attributeTabDao;
	}
	
}